//随机生成id
let unReadNum = 0
function handleResponse(params){
  params = params && JSON.parse(params)
  switch(params.type){
    case 'ADD':
      unReadNum++
      break;
    case 'REDUCE':
      unReadNum--
      break;
  }
  const res = {
    traceId:params.traceId || params.id,
    type:"MESSAGE_CENTER",
    content:{
      action:params.type,
      msg:params.messsageInfo || '',
      unReadNum
    }
  }
  return JSON.stringify(res)
}
function connectSuccResponse(params){
  const res = {
    traceId: '',
    type:"MESSAGE_CENTER",
    content:{
      action:null,
      msg:"已成功连接",
      unReadNum
    }
  }
  return JSON.stringify(res)
}
module.exports = {
  handleResponse,
  connectSuccResponse
}